package smetana.modules.business;

import com.google.inject.AbstractModule;
import com.google.inject.matcher.Matchers;

import org.apache.ibatis.session.SqlSession;
import smetana.ibatis.SqlSessionProvider;
import smetana.modules.business.interceptor.IBatisMethodInterceptor;

/**
 * @author dmitry.mamonov
 */
public class ModuleBusiness extends AbstractModule {

    @Override
    protected void configure() {
        bind(SqlSession.class).toProvider(SqlSessionProvider.class);
        bind(BusinessAgent.class).to(BusinessAgentImpl.class);
        bind(BusinessDoc.class).to(BusinessDocImpl.class);
        bind(BusinessDocPosition.class).to(BusinessDocPositionImpl.class);
        bind(BusinessManager.class).to(BusinessManagerImpl.class);
        bind(BusinessPivot.class).to(BusinessPivotImpl.class);
        bind(BusinessPosition.class).to(BusinessPositionImpl.class);
        bind(BusinessSupplier.class).to(BusinessSupplierImpl.class);
        bindInterceptor(
                Matchers.subclassesOf(BaseImpl.class),
                Matchers.any(),
                new IBatisMethodInterceptor());
    }
}
